<template>
  <el-dialog
    v-if="show"
    v-model="dialog"
    title="设备详情"
    class="EquipmentDetailDialog"
    width="50%"
    :close-on-click-modal="false"
    :before-close="handleClose"
  >
    <template #default>
      <el-row>
        <el-col :span="16">
          <div class="my_card">
            <div class="header">设备基本信息</div>
            <el-row class="elrow">
              <el-col :span="6">
                <div class="title">车牌号</div>
                <span>{{ detail.vehicleNo }}</span>
              </el-col>
              <el-col :span="6">
                <div class="title">充电设备编号</div>
                <span>{{ detail.bmsNo }}</span>
              </el-col>
              <el-col :span="6">
                <div class="title">运营商编号</div>
                <span>{{ detail.operatorId }}</span>
              </el-col>
              <el-col :span="6">
                <div class="title">代充人员或司机</div>
                <span>{{ detail.workerId }}</span>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="my_card">
            <div class="header">投资基本信息</div>
            <el-row class="elrow">
              <el-col :span="8">
                <div class="title">投资时间</div>
                <span>{{ detail.investDate }}</span>
              </el-col>
              <el-col :span="8">
                <div class="title">总收益</div>
                <span>{{ detail.totalMoney }}</span>
              </el-col>
              <el-col :span="8">
                <div class="title">分润比例</div>
                <span>{{ detail.rate }}</span>
              </el-col>
              <el-col :span="8">
                <div class="title">投资总收入</div>
                <span>{{ detail.investTotalIncome }}</span>
              </el-col>
              <el-col :span="8">
                <div class="title">分管运营人</div>
                <span>{{ detail.operatorPerson }}</span>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="my_card">
            <div class="header">设备工作基本信息</div>
            <el-row class="elrow">
              <el-col :span="8">
                <div class="title">设备状态</div>
                <span>{{ statusNum(detail.status) }}</span>
              </el-col>
              <el-col :span="8">
                <div class="title">绑定状态</div>
                <span>{{ isBindingNum(detail.isBinding) }}</span>
              </el-col>
              <el-col :span="8">
                <div class="title">所属街道</div>
                <span>{{ detail.orgName }}</span>
              </el-col>
              <el-col :span="8">
                <div class="title">已工作时长 (h)</div>
                <span>{{ detail.workerTime }}</span>
              </el-col>
              <el-col :span="8">
                <div class="title">已工作电量 (kwh)</div>
                <span>{{ detail.electricity }}</span>
              </el-col>
              <el-col :span="8">
                <div class="title">当前电量 (kwh)</div>
                <span>{{ detail.nowElectricity }}</span>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="8" style="padding-left: 20px">
          <div class="my_card">
            <div class="header">设备报修记录</div>
            <el-row class="elrow flexBetween">
              <div>
                <p  class="fontTitle">2023/02/20 17:22</p>
                <p>故障报修</p>
              </div>
              <div>
                <p class="fontTitle">报修人</p>
                <p>张涛</p>
              </div>
          </el-row>
          <el-row class="elrow flexBetween">
              <div>
                <p  class="fontTitle">2023/02/20 17:22</p>
                <p>故障报修</p>
              </div>
              <div>
                <p class="fontTitle">报修人</p>
                <p>张涛</p>
              </div>
          </el-row>
          </div>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="16">
          <div class="my_card">
            <div class="header">设备绑定记录</div>
            <el-row class="elrow"> 暂无 </el-row>
          </div>
        </el-col>
      </el-row>

      <!-- <footer> -->
      <!-- <el-button type="danger" @click="delBtn">删除设备</el-button> -->
      <!-- </footer> -->
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref, withDefaults } from 'vue'

interface Props {
  show: boolean
  detail: any
}
const dialog = ref(true)
withDefaults(defineProps<Props>(), {
  show: false,
  detail: {},
})
const emit = defineEmits<{
  (event: 'update:show', val: boolean): void
  (event: 'delEquipment', val: string): void
}>()
//弹框关闭
const handleClose = () => {
  emit('update:show', false)
}

const statusNum = (value: number) => {
  let obj: any = {
    0: '离线',
    1: '在线',
  }
  return obj[value]
}

const isBindingNum = (value: number) => {
  let obj: any = {
    0: '未绑定',
    1: '已绑定',
  }
  return obj[value]
}

//删除设备
// const delBtn = () => {
//   emit('delEquipment', '1')
// }
</script>

<style lang="scss">
.EquipmentDetailDialog {
  .el-dialog__body {
    padding: 0px 20px 10px;
  }
  footer {
    margin: 20px 0 10px;
    text-align: center;
  }
  .fontTitle{
    color:  #B1B3B8;
    font-size: 12px;
  }
  .my_card {
    border: 1px solid rgba(220, 221, 221, 1);
    border-radius: 10px;
    // padding: 13px 0;
    margin-bottom: 10px;
    .header {
      color: #101010;
      font-size: 16px;
      border-bottom: 1px solid rgba(220, 221, 221, 1);
      padding: 10px 24px;
      font-weight: 600;
    }
    .flexBetween {
      display: flex;
      width: 100%;
      justify-content: space-between;
      .leftTitle {
        width: 70px;
        display: inline-block;
      }
    }
    .price {
      display: inline-block;
      width: 30px;
    }
    .fontBold {
      font-weight: bold;
      color: #333;
      font-size: 15px;
    }
    .elrow {
      // text-align: right;
      border-top: 1px solid rgba(220, 221, 221, 1);
      padding: 10px 24px;
      .title {
        font-weight: 600;
        color: #333;
        text-align: left;
      }

      .flexBox {
        display: flex;
        align-items: center;
        p {
          margin: 0 10px;
        }
        .remark {
          color: #a7a7b3;
        }
        .el-icon {
          margin-right: 5px;
        }
      }
      .el-col {
        margin-bottom: 10px;
      }
    }
    .elrow:nth-child(2) {
      border-top: none !important;
    }
    .operate {
      color: #409eff;
      margin-left: 10px;
      cursor: pointer;
    }
  }
}
</style>
